//
//  vector_demo.cpp
//  cpp_learn
//
//  Created by 李贺 on 2021/12/15.
//

#include "vector_demo.hpp"

namespace vector_demo {

void vector_constructor() {
    vector<int> first;
    vector<int> second(3);
    vector<int> third(5, 100);
    vector<int> forth(third.begin(), third.end());
    int myints[] = {16,2,77,29};
      std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
    
    vector<int>::iterator it = first.end();
    auto it1 = first.begin();
}

void jieyinyong(){
    vector<string> arr = {"aaa", "bbb"};
    auto begin = arr.begin();
    
    if (begin->empty()) {
        string s1("aaa");
        begin->append(s1);
        cout << "empty" << endl;
    } else {
        cout << "not empty" << endl;
    }
}

void emplace_demo() {
    vector<int> vec = {10,20,30};
    vec.emplace(vec.begin(), 99);
    for (auto x: vec) {
        cout << x << endl;
    }
}

void test_vector(){
    emplace_demo();
}
}
